package com.karst.essentials.chapter04
{
	import flash.events.Event;
	
	import org.papervision3d.materials.MovieAssetMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.view.BasicView;

	internal class MovieAssetMaterialExample extends BasicView
	{
		public function MovieAssetMaterialExample()
		{
			super() ;
			createView() ;
			startRendering() ;
		}
		
		private var material : MovieAssetMaterial = null ;
		private var plane : Plane = null ;
		private function createView() : void
		{
			if( material == null ) 
			{
				try
				{
					material = new MovieAssetMaterial( "assetsMc" ) ;
				}
				catch( error : Error )
				{
					trace( "MovieAssetMaterial can be used by Flash IDE only!" ) ;
				}
			}
			if( plane == null )
			{
				plane = new Plane( material, 400, 400, 10, 8 ) ;
				plane.material.doubleSided = true ;
			}
			
			scene.addChild( plane ) ;
		}
		
		override protected function onRenderTick(event:Event=null):void
		{
			super.onRenderTick( event ) ;
			if( plane )
				plane.localRotationY-- ;
		}
	}
}